{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
}}

<div class="action-block is-rounded" data-test-demote-replication>
  <div class="action-block-info">
    <h3 class="title is-5 is-marginless">
      Demote cluster
    </h3>
    <p class="has-top-padding-s">
      Demote this
      {{this.model.replicationModeForDisplay}}
      primary to a secondary.
    </p>
  </div>
  <div class="action-block-action">
    <Hds::Button
      @text="Demote"
      @color="secondary"
      {{on "click" (action (mut this.isModalActive) true)}}
      data-test-button="demote"
    />
  </div>
</div>

<ConfirmationModal
  @title="Demote to secondary?"
  @onClose={{action (mut this.isModalActive) false}}
  @isActive={{this.isModalActive}}
  @confirmText={{this.model.replicationModeForDisplay}}
  @toConfirmMsg="demoting this cluster"
  @onConfirm={{action "onSubmit" "demote" this.model.replicationAttrs.modeForUrl}}
>
  <p class="has-bottom-margin-m">
    {{#if (and (eq this.replicationMode "dr") (not this.model.performance.replicationDisabled))}}
      <p class="has-bottom-margin-m" data-test-demote-warning>
        This cluster is currently operating as a performance secondary. Demoting it will leave your replication setup
        <strong>without a performance primary cluster</strong>
        until a new cluster is promoted.
      </p>
    {{/if}}
    Demoting this
    {{this.model.replicationModeForDisplay}}
    primary to a
    {{this.model.replicationModeForDisplay}}
    secondary means that the resulting secondary cluster:
  </p>
  <ul class="bullet has-bottom-margin-m">
    {{#if (and (eq this.replicationMode "dr") (not this.model.performance.replicationDisabled))}}
      <li>Will be read-only</li>
    {{/if}}
    <li>Will not attempt to connect to a primary</li>
    <li>Will maintain knowledge of its cluster ID</li>
    <li>Can be reconnected to the same set of replication clusters without wiping local storage.</li>
  </ul>
  <p class="has-bottom-margin-m">
    To connect the resulting secondary to a new primary, use the Update primary action.
  </p>
</ConfirmationModal>